package com.simple.javatraining.testing.checker;

import com.simple.javatraining.testing.questionsformer.HardcodedQuestionsFormer;
import com.simple.javatraining.testing.testinside.questions.Question;

public class Checker {	
	private double[] listOfResults;
	private HardcodedQuestionsFormer hardcodedQuestions =
                                               HardcodedQuestionsFormer.getHardcodedQuestions();
	
	public Checker() {
		this.listOfResults = new double[hardcodedQuestions.getNumberOfQuestions()];
	}
	
	public void addCurrentResultToList (double resultToAdd, Question currentQuestion) {
		int indexOfResult = hardcodedQuestions.getIndexOfQuestion(currentQuestion);
		listOfResults[indexOfResult] = resultToAdd;		
    }

	public  double calculateSummaryResultInPercents() {
	    double summaryResult = 0;
	    for (double currentResult:listOfResults) {
	        summaryResult += currentResult;
	    }
	    return 100.0*(summaryResult/listOfResults.length);
	}	

}